package com.tuniu.agents.impl.hotel.logger;

import com.tuniu.agents.common.i18n.I18nConstants;
import com.tuniu.agents.impl.hotel.constants.HotelConstants;
import com.tuniu.agents.message.AgentLogger;
import com.tuniu.agents.message.MessageRender;
import com.tuniu.agents.util.I18nUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service(HotelAgentLoggingService.BEAN_NAME)
@Slf4j
public class HotelAgentLoggingService implements AgentLogger {

    public static final String BEAN_NAME = "hotelAgentLoggingService";
    @Autowired
    private MessageRender messageRender;
    @Override
    public List<String> before(String conversationId, Object messages) {;
        String acceptLanguage = I18nUtil.getLocaleLanguageTag(conversationId);
        String markdownResponse = messageRender.renderTemplate(HotelConstants.THINKING_ASSISTANT_TEMPLATE_NAME,
                Map.of(I18nConstants.LANGUAGE_TAG, acceptLanguage),
                Map.of(I18nConstants.TEMPLATE_ASSISTANT,I18nUtil.getMessage(conversationId,HotelConstants.HOTEL_TEMPLATE_ASSISTANT)));
        return List.of(markdownResponse);
    }

    @Override
    public List<String> after(String conversationId, Object messages, Object result) {
        return null;
    }
}
